home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4360 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: mudskipper.cac.psu.edu!user
  2. From: fcusack@tdx.org (frank.)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, argv, strcmp()
  5. Date: Sat, 03 Feb 1996 19:02:11 -0400
  6. Organization: Penn State University, Center for Academic Computing
  7. Message-ID: <fcusack-0302961902110001@mudskipper.cac.psu.edu>
  8. References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu> <4f0rjn$sfh@news.iag.net>
  9. NNTP-Posting-Host: mudskipper.cac.psu.edu
  10.  
  11. In article <4f0rjn$sfh@news.iag.net>, jatmon@iag.net (John R Buchan) wrote:
  12.  
  13. > In article <fcusack-0202961621470001@mudskipper.cac.psu.edu>, fcusack@tdx.org 
  14. > says...
  15. > >
  16. > >In article <4etj7c$bma@news.iag.net>, jatmon@iag.net (John R Buchan) wrote:
  17. > >
  18. > >> In article <11f7cc$17261a.3b3@daprez>, otisg@panther.middlebury.edu says...
  19. > >> >
  20. > <snip>
  21. [..]
  22. > >> >
  23. > >> >  if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
  24. > >> >    Usage();
  25. > >> >  }
  26. > >> <snip>
  27. > >> 
  28. > >> I assume you mean this to call Usage if argv[1] is not "-e" and not "-d"?
  29. > >> Change the || to &&.  
  30. > >
  31. > >The && test would _never_ pass. argv[1] could never be both "-d" and "-e".
  32. > You are correct, of course.  Stupidity on my part. I tend to get careless 
  33. > about strcmp's reverse logic (ie returns False, when the strings match), when
  34. > I am not paying attention (not an excuse, just an explanation).  I normally 
  35. > compare the return value to 0, just to keep myself straight.  
  36.  
  37. I hate strcmp also. c++ shines here, you can just overload ==.
  38.  
  39. > >The || is correct here.
  40. > <snip>
  41.  
  42. This is of course wrong though. I always have a hard time with strcmp...
  43.  
  44. >   if ( strcmp(argv[1],"-d") && strcmp(argv[1],"-e") ) 
  45.  
  46. much better. :)
  47. ~Frank
  48.  -- I am Pentium of Borg.  Division is futile.  You will be approximated. --
  49.  --   If you build it, they will come --> http://www.tdx.org/~fcusack/    --
  50.  -- PGP key fingerprint: 01 C0 C0 B9 CC 78 67 0F  3F 64 80 65 8B 0F F9 EA --
  51.